//
//  TBRRentDetailCarPersonCell.m
//  TBRentClient
//
//  Created by tonbright on 2018/5/14.
//  Copyright © 2018年 tonbright. All rights reserved.
//
#define kPictureMargin 0
#import "TBRRentDetailCarPersonCell.h"
#import "TBRRentDetailCarCollectionCell.h"
#import "SCAdView.h"
#import "TBRCarBasicModel.h"
#import "TBRDetailCostC.h"
#import "TBRChooseCouponListC.h"
#import "NSString+category.h"
@interface TBRRentDetailCarPersonCell()<SCAdViewDelegate>
@property (weak, nonatomic) IBOutlet UIPageControl *pageController;
@property (weak, nonatomic) IBOutlet UIView *view_collection;
@property (nonatomic,strong)SCAdView *adView;

@property (weak, nonatomic) IBOutlet UILabel *lbe_price;

@property (weak, nonatomic) IBOutlet UILabel *lbe_disCount;
@property (weak, nonatomic) IBOutlet UILabel *lbe_titleName;

@end
@implementation TBRRentDetailCarPersonCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [_pageController setValue:[UIImage imageNamed:@"fengexian"] forKeyPath:@"pageImage"];
    [_pageController setValue:[UIImage imageNamed:@"fengexian_select"] forKeyPath:@"currentPageImage"];
    _pageController.currentPage = 0;
    NSString *priceText = @"预计 720.0 元";
    NSString *disCountText = @"券已抵扣 80.0 元";
    NSMutableAttributedString *tmpPriceText = [NSString changeTextColor:priceText OneColor:[UIColor blackColor] TwoColor:[UIColor redColor] oneFontSize:14 twoFontSize:18 Range:NSMakeRange(3, 5)];
    
    NSMutableAttributedString *tmpDisCountText = [NSString changeTextColor:disCountText OneColor:[UIColor blackColor] TwoColor:[UIColor redColor] oneFontSize:14 twoFontSize:14 Range:NSMakeRange(5, 4)];
    
    _lbe_price.attributedText = tmpPriceText;
    _lbe_disCount.attributedText = tmpDisCountText;
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    NSArray *textArray =@[@"car",@"car",@"car",@"car"];
    SCAdView *adView = [[SCAdView alloc] initWithBuilder:^(SCAdViewBuilder *builder) {
        builder.adArray = textArray;
        builder.viewFrame = CGRectMake(0, 0, Width-20, 195);
        builder.adItemSize = (CGSize){(Width - 20)/1.85f,195};
        builder.minimumLineSpacing = 0;
        builder.secondaryItemMinAlpha = 0.6;
        builder.threeDimensionalScale = 1.38;
        builder.itemCellNibName = @"TBRRentDetailCarCollectionCell";
    }];
    adView.delegate = self;
    [self.view_collection insertSubview:adView atIndex:0];
//    [self.view_collection addSubview:adView];
}

- (void)refreshUI {
    
}

- (IBAction)btnClick:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(rentDetailCarPersonCellTimePersonBtnClick:)]) {
        [self.delegate rentDetailCarPersonCellTimePersonBtnClick:sender.tag];
    }
}

- (void)sc_didClickAd:(id)adModel {
    
}

- (void)sc_scrollToIndex:(NSInteger)index {
    self.pageController.currentPage = index;
}


- (IBAction)carBtnClick:(UIButton *)sender {
    if (sender.tag == 10) {
        TBRDetailCostC *detailC = [[TBRDetailCostC alloc] init];
        [[HelpObject getCurrentNav] pushViewController:detailC animated:YES];
    }
    else {
        TBRChooseCouponListC *chooseCouponListC = [[TBRChooseCouponListC alloc] init];
        [[HelpObject getCurrentNav] pushViewController:chooseCouponListC animated:YES];
        
    }
}

@end
